<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Eros Tours App Engine</title>
<link rel="stylesheet" type="text/css" href="css/flexigrid/flexigrid.css">
<script type="text/javascript" src="lib/jquery/jquery.js"></script>
<script type="text/javascript" src="js/flexigrid.js"></script>
<script type="text/javascript" src="js/val.js"></script>
<script type="text/javascript" src="js/jquery.tokeninput.js"></script>
<script type="text/javascript" src="js/jquery_json.js"></script>
<script language="javascript" src="js/jquery.datePicker.js"></script>
<script language="javascript" src="js/date.js"></script>
<link rel="stylesheet" type="text/css" href="css/datePicker.css" />
<link rel="stylesheet" href="css/token-input.css" type="text/css" />
<script type="text/javascript">
$(document).ready(function(){
	$("#loading-page").ajaxStart(function(){
		$(this).show();
	});
	$("#loading-page").ajaxStop(function(){
		$(this).hide();
	});
	$("#popupContactClose").click(function(){
		disablePopup();
	});
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	$("#popupContactClose1").click(function(){
		disablePopup();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
});
	function show_config()
	{
		jQuery("#flex1").flexReload(); 
		$("#confi").show();
		$("#showdivreq").hide();
		$("#requ").hide();
		$("#showdivcon").show();
	}
</script>
<style>
body {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	padding:0px;
	margin:0px;
	font-family:segoe UI, Arial;
}
.flexigrid div.fbutton .add {
	background: url(css/images/add.png) no-repeat center left;
}
.flexigrid div.fbutton .delete {
	background: url(css/images/close.png) no-repeat center left;
}
.flexigrid div.fbutton .addcon {
	background: url(css/application_add.png) no-repeat center left;
}
.flexigrid div.fbutton .addmak {
	background: url(css/money_add.png) no-repeat center left;
}
.flexigrid div.fbutton .delmak {
	background: url(css/money_delete.png) no-repeat center left;
}

input {
	font-family:segoe UI, Arial;
	font-size:12px;
}
select {
	font-family:segoe UI, Arial;
	font-size:12px;
}
a.dp-choose-date {
    float: left;
    width: 16px;
    height: 16px;
    padding: 0;
    margin: 5px 3px 0;
    display: block;
    text-indent: -2000px;
	position:relative;
	left:-21px;
	bottom:3px;
    
    background: url(calendar.png) no-repeat; 
}
a.dp-choose-date.dp-disabled {
    background-position: 0 -20px;
    cursor: default;
}
</style>
</head>
<!-- This is grid view that show all the configuration which is existing or creating by Admin and then every configuration have a default markup. then after it will edited or new markup will created by the admin. So there is some fuction which is done all the performance with click option and all the function will have some PHP and JS file which is included and also some css file for some jquery plugin  -->
<body>
<div id="showdivcon" style="width:100%; background-color:#FFC; border-bottom:solid 1px #FC6; padding-top:2px; padding-bottom:2px; font-size:18px; font-family: 'segoe UI', Arial; font-weight: bold;">
  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="22%" > <span style="font-weight:bold; font-size:18px">EROS TOURS  APPS <span style="color: #06F"></span></span></td>
      <td width="56%" align="center" valign="middle"><img src="18-0.gif" id="loading-page" style=" display:none"  />
      </td>
      <td width="22%"></td>
    </tr>
  </table>
  <a href="#"  style="text-decoration:none;" ></a></div>
<div id="showdivreq" style=" display:none;width:100%; background-color:#FFC; border-bottom:solid 1px #FC6;  font-size:12px; padding:10px;"><a href="#" style="text-decoration:none; " >&raquo; Show All Configuration</a> | <a href="#"  style="text-decoration:none;" >&raquo; Add New Request</a></div>
<table width="800" border="0" align="center" cellpadding="4" cellspacing="1">
  <tr>
    <td id="confi"><table id="flex1" style="display:none" >
    </table>
    </td>
  </tr>
  <tr>
    <td id="requ">   </td></tr>
</table>
<table width="800" border="0" align="center" cellpadding="4" cellspacing="1">
  <tr>
    <td><div id="del" style="display:none; background-color: #FFC; border: 1px solid #FC6; margin-top:10px; text-align:center; padding:4px;"></div>&nbsp;</td>
  </tr>
</table>
<script type="text/javascript">
//This function is for the show the Request Grid which is created against there configuration Id. and if there is no any request then it's show 0 request in grid................................................................................

var global_config;
function show_request(config_id)
{			
	global_config=config_id;
	$("#requ").show();
	$("#requ").html('<table id="flex2" style="display:none" ></table>');
	$("#flex2").flexigrid
			(
			{
			url: 'view_request.php',
			dataType: 'json',
			colModel : [
				{display: 'Id', name : 'idRequests', width : 20, sortable : true, align: 'center'},
				{display: 'Option', name : 'option', width : 173, sortable : true, align: 'left'},
				{display: 'PTC', name : 'ptc', width : 75, sortable : true, align: 'left'},
				{display: 'Include Airline', name : 'inc_arl', width : 100, sortable : true, align: 'left'},
				{display: 'Exclude Airline', name : 'exc_arl', width : 100, sortable : false, align: 'left'},
				{display: 'Connection City', name : 'con_city_cod', width : 30, sortable : false, align: 'center'},
                {display: 'Sid', name : 'sid', width : 30, sortable : false, align: 'center'},
				{display: 'Alt', name : 'alt', width : 30, sortable : false, align: 'center'},
				{display: 'Status', name : 'status', width : 35, sortable : false, align: 'center'},
				{display: 'Edit', name : 'Edit', width : 20, sortable : false, align: 'center'},
				{display: 'View', name : 'View', width : 25, sortable : false, align: 'center'},
				{display: 'Test', name : 'Test', width : 25, sortable : false, align: 'center'},
				{display: 'Del', name : 'Delete', width : 20, sortable : false, align: 'center'}
				],
					buttons : [
				{name: 'Show All Coniguration', bclass: 'addcon', onpress:show_config},
				{separator: true},
				{name: 'Add Request', bclass: 'add',  onpress:create_request},
				{separator: true}
				],
			searchitems : [
				{display: 'Config Id', name : 'config_id'}
				],
			sortname: "idRequests",
			sortorder: "asc",
			usepager: true,
			title: 'Request of '+ config_id,
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			height:200,
			query: config_id,
			singleSelect: true,
			onSubmit: addFormData
			}
			);
			$("#confi").hide();
}
//............................................End Show Request Grid.................................................................
// This function call for Create request ...........................................................................................
function create_request()
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Request Form....</div>");
$.ajax({
   type: "POST",
   url: "create_request.php",
   data:$("#create_request").serialize()+"&config_id="+global_config,
	   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/edit_request_call.js",
	  dataType: "script"
	});
   }
 });
}
//.....................................................................//
function edit_request(request_id,config)
{
	centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Request Form....</div>");
$.ajax({
   type: "POST",
   url: "update_request.php",
   data:$("#update_request").serialize()+"&config_id="+config+"&request_id="+request_id,
   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/edit_request_call.js",
	  dataType: "script"
	});
   }
 });
}
//.......................................................Function End..................................
// this function for the test markup ...............................................................
function test_request(request_id,config)
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Request Form....</div>");
$.ajax({
   type: "POST",
   url: "test_request.php",
   data:"config_id="+config+"&request_id="+request_id,
   success: function(msg){
	   $("#contactArea").html("");
	  
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/test_request_call.js",
	  dataType: "script"
	});
   }
 });
}
//.......................................................Function End..................................
//This function is for the show the markup grid view which is created against there configuration Id. and if there is no any request then it's show default markup in grid............................................................................
var global_markup;
function show_markup(config_id)
{	
	global_markup=config_id;
	$("#requ").show();
	$("#confi").hide();
	$("#requ").html('<table id="flex2" style="display:none" ></table>');
	$("#flex2").flexigrid
			(
			{
			url: 'view_markup.php',
			dataType: 'json',
			colModel : [
					{display: 'Start Date', name : 'start_date', width :60, sortable : true, align: 'center'},
				{display: 'End Date', name : 'end_date', width : 60, sortable : true, align: 'left'},
				{display: 'Fare Type', name : 'fare_type', width : 50, sortable : true, align: 'left'},
				{display: 'Airline Code', name : 'airline_code', width : 80, sortable : true, align: 'left'},
				{display: 'Type', name : 'trip_type', width : 30, sortable : false, align: 'left'},
				{display: 'PTC', name : 'ptc', width : 30, sortable : false, align: 'center'},
				{display: 'Cabin', name : 'cabin_class', width : 60, sortable : false, align: 'center'},
				{display: 'Sid', name : 'sid', width : 30, sortable : false, align: 'center'},
				{display: 'Range', name : 'range', width : 40, sortable : false, align: 'center'},
				{display: 'Time', name : 'time_search', width : 35, sortable : false, align: 'center'},
				{display: 'Flight Type', name : 'flight_type', width : 58, sortable : false, align: 'center'},
				{display: 'M Type', name : 'rule_id', width : 40, sortable : false, align: 'center'},
				{display: 'M V Type', name : 'rule_id', width : 55, sortable : false, align: 'center'},
				{display: 'M Apply', name : 'rule_id', width : 45, sortable : false, align: 'center'},
				{display: 'M Value', name : 'rule_id', width : 45, sortable : false, align: 'center'},
				{display: 'Edit', name : 'rule_id', width : 30, sortable : false, align: 'center'},
				{display: 'Delete', name : 'rule_id', width : 30, sortable : false, align: 'center'}
				],
					buttons : [
				{name: 'Show All Configuration', bclass: 'addcon' , onpress:show_config	},
				{separator: true},
				{name: 'Add MarkUp', bclass: 'addmak' , onpress:create_markup	},
				{separator: true}
				],
			searchitems : [
				{display: 'Config Id', name : 'config_id'}
				],
			sortname: "idRequests",
			sortorder: "asc",
			usepager: true,
			title: 'Mark Up of '+ config_id,
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 1000,
			height: 200,
			query: config_id,
			singleSelect: true,
			onSubmit: addFormData
			}
			);
}
//..............................................End Markup Grid View..........................................................................
// This function for the test markup that markup is created or not if not then default markup show .......................................................

function test_markup()
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Markup Test Form....</div>");
$.ajax({
   type: "POST",
   url: "test_markup.php",
   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/test_markup_call.js",
	  dataType: "script"
	});
   }
 });
}
//.........................................Function end.....................................................................


/*function view_request(request_id)
{
	
	centerPopup();
		//load popup
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Request Form....</div>");
		
$.ajax({
   type: "POST",
   url: "update_request.php",
   data: "request_id="+request_id,
   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	   
	   
	$.ajax({
	  type: "GET",
	  url: "js/edit_request_call.js",
	  dataType: "script"
	});
   }
 });

}*/

// This function Create New configuration ....................................................................................... 
function create_config()
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Configuration Form....</div>");
$.ajax({
   type: "POST",
   url: "create_config.php",
	   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/edit_config_call.js",
	  dataType: "script"
	});
   }
 });
}
//........................................ Function End ..........................................
// This Function for Edit the created Configuration ......................................................
function edit_config(config)
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Configuration Form....</div>");
$.ajax({
   type: "POST",
   url: "edit_config.php",
   data: "config_id="+config,
   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/edit_config_call.js",
	  dataType: "script"
	});
  }
 });
}
//................................................................Function end .......................................
// This Function For the Create new Markup with respect to existing configuration ..................................
function create_markup()
{
		centerPopup();
		loadPopup();
		$("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Markup Form....</div>");
$.ajax({
   type: "POST",
   url: "create_markup.php",
   data:"region="+global_markup,
	   success: function(msg){
	   $("#contactArea").html("");
	   $("#contactArea").html(msg);
	$.ajax({
	  type: "GET",
	  url: "js/edit_markup_call.js",
	  dataType: "script"
	});
   }
 });
}
// ....................................... Function End ........................................................
// This function for the Edit the existing Markup ..............................................................
function edit_markup(rule_id)
{
               centerPopup();
               loadPopup();
               $("#contactArea").html("<div style='padding-top:120px; text-align:center;'><img src='18-0.gif' align='absmiddle'><br>Loading Markup Form....</div>");
$.ajax({
  type: "POST",
  url: "edit_markup.php",
  data:"rule_id="+rule_id,
          success: function(msg){
          $("#contactArea").html("");
          $("#contactArea").html(msg);
       $.ajax({
         type: "GET",
         url: "js/update_markup_call.js",
         dataType: "script"
       });
  }
});
}

// This is the Main Grid which is the load with index.html file ...........................................
$("#flex1").flexigrid({
			url: 'view_config.php',
			dataType: 'json',
			colModel : [
				{display: 'Id', name : 'idConfiguration', width : 30, sortable : true, align: 'center'},
				{display: 'Depart', name : 'dep_code', width : 205, sortable : true, align: 'left'},
				{display: 'Return', name : 'arr_code', width : 205, sortable : true, align: 'left'},
				{display: 'Status', name : 'arr_code', width : 50, sortable : true, align: 'center'},
				{display: 'Date', name : 'Date', width : 60, sortable : false, align: 'center'},
				{display: 'Req', name : 'Request', width : 50, sortable : false, align: 'center'},
				{display: 'Mark', name : 'markup', width : 30, sortable : false, align: 'center'},
				{display: 'Edit', name : 'Edit', width : 30, sortable : false, align: 'center'},
				{display: 'Del', name : 'Delete', width : 30, sortable : false, align: 'center'}
				],
			buttons : [
				{name: 'Create New Configuration', bclass: 'addcon' , onpress:create_config	},
				{separator: true},
				{name: 'Test Mark Up', bclass: 'addcon' , onpress:test_markup	},
				{separator: true}
				],
			searchitems : [
				{display: 'Depart', name : 'dep_code'}
				],
			sortname: "idConfiguration",
			sortorder: "asc",
			usepager: true,
			title: 'Configuration List',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 800,
			onSubmit: addFormData,
			autoload:true,
			singleSelect: true
			}
			);
// ........................ The Main Grid End ..........................................................................................................
//This is the function which is for the delete the created configuration .................................................................
function delete_config(config){
	$.ajax({
   type: "POST",
   url: "delete_config.php",
   data: "config_id="+config,
   success: function(msg){
	if(msg=="true")
	{
		jQuery("#flex1").flexReload(); 
		$("#del").fadeIn(500);
		$("#del").html("<span style='color:green;'><img src='accept.png' align='absmiddle'> Configuration deleted!</span>");
		$("#del").fadeOut(10000);
	}
	else{
		$("#del").fadeIn(500);
    	$("#del").html("<span style='color:#FF0000;'><img src='delete.png' align='absmiddle'> Please Delete All Requests before you delete Configuration.</span>");$("#del").fadeOut(10000);
		}
   }
	});
	}
// ............................................. Function end .................................................
// This is function which is delete the created markup .......................................................
function delete_markup(rule_id,config_id){
	$.ajax({
   type: "POST",
   url: "delete_markup.php",
   data: "rule_id="+rule_id+"&config_id="+config_id,
   success: function(msg){
	if(msg=="true")
	{
		jQuery("#flex2").flexReload(); 
		$("#del").fadeIn(500);
		$("#del").html("<span style='color:green;'><img src='accept.png' align='absmiddle'> Markup deleted!</span>");
		$("#del").fadeOut(10000);
	}
	else{
		$("#del").fadeIn(500);
		$("#del").html("<span style='color:#FF0000;'><img src='delete.png' align='absmiddle'> We Have a ERROR ..</span>");
		$("#del").fadeOut(10000);
		}
   }
	});
	}
//................................... Function end ............................................................
// This is the function which deleted the Request ..............................................................
function delete_request(request){
	$.ajax({
   type: "POST",
   url: "delete_request.php",
   data: "request_id="+request,
   success: function(msg){
	if(msg=="true")
	{
		jQuery("#flex2").flexReload(); 
		$("#del").fadeIn(500);
		$("#del").html("<span style='color:green;'><img src='accept.png' align='absmiddle'> Request deleted!</span>");
		$("#del").fadeOut(10000);
	}
	else{
		$("#del").fadeIn(500);
		$("#del").html("<span style='color:#FF0000;'><img src='delete.png' align='absmiddle'> Server Error :: Please Retry</span>");
		$("#del").fadeOut(10000);
		}
   }
	});
	}
//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
function addFormData()
	{
	//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
	var dt = $('#sform').serializeArray();
	$("#flex1").flexOptions({params: dt});
	return true;
	}
$('#sform').submit
(
	function ()
		{
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		}
);						
</script>
<div id="popupContact"> <a id="popupContactClose"><img src="cancel.png" style="cursor:pointer;" /></a>
  <p id="contactArea"> </p>
</div>
<div id="popupContact1"> <a id="popupContactClose1">x</a>
  <p id="contactArea1"> </p>
</div>
<div id="backgroundPopup"></div>
<div id="ttt"></div>
</body>
</html>